| Conditions | 5 |
| Total Lines | 15 |
| Code Lines | 13 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | import {PollState, taskEvent} from '../helpers/interfaces'; |
||
| 12 | |||
| 13 | async process(): Promise<void> { |
||
| 14 | switch (this.event.action) { |
||
| 15 | case 'close_poll': |
||
| 16 | const currentState = await this.getStateFromMessageId(); |
||
| 17 | if (!currentState.closedTime || currentState.closedTime > Date.now()) { |
||
| 18 | currentState.closedTime = Date.now(); |
||
| 19 | } |
||
| 20 | const apiResponse = await this.updatePollMessage(currentState); |
||
| 21 | if (apiResponse?.status !== 200) { |
||
| 22 | throw new Error('Error when closing message'); |
||
| 23 | } |
||
| 24 | break; |
||
| 25 | default: |
||
| 26 | console.log('unknown task'); |
||
| 27 | } |
||
| 52 |